using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class SendSex : MonoBehaviour {
	
	public GameDefine.Sex sex = GameDefine.Sex.MALE;
	
	public ModelDisplay modelDisplay;
	
	public UISprite headPictureSprite;
	
	int id;
	UICheckbox checkBox;
	List<UIAtlas.Sprite> spriteList;
	
	void Start(){
		id = (int)sex;
		
		checkBox = GetComponent<UICheckbox>();
		
		spriteList = headPictureSprite.atlas.spriteList;
		
		if(checkBox.isChecked){
			CreateRoleInfo.GetInstance().Sex = id;
			
			ModifyHeadPicture();
			CreateRoleInfo.GetInstance().HeadPicName = headPictureSprite.spriteName;
		}
	}
	
	void OnClick(){
		modelDisplay.ShowSex(id);
		
		ModifyHeadPicture();
		
		CreateRoleInfo.GetInstance().Sex = id;
		CreateRoleInfo.GetInstance().HeadPicName = headPictureSprite.spriteName;
	}
	
	void ModifyHeadPicture(){
		switch(sex){
			case GameDefine.Sex.MALE:
				headPictureSprite.spriteName = GameDefine.HEADPICPRE_MALE + "_01";
				break;
			case GameDefine.Sex.FEMALE:
				headPictureSprite.spriteName = GameDefine.HEADPICPRE_FEMALE + "_01";
				break;
			default:
				break;
		}
	}
}
